﻿using UnityEngine;
using System.Collections;

public class EnemyFire : MonoBehaviour {
    public Transform FirePoints;
    float lastfireTime;
    GameObject bulletPrefab;
    float interval;
    float time=1;
    float speed = 5;
    void Start () {
        bulletPrefab = Resources.Load<GameObject>("Bullet/Bullet2");
        interval = 1f / time;
    }
	
	// Update is called once per frame
	void Update () {
        if (Time.time - lastfireTime > interval)
        {
            lastfireTime = Time.time;
            EnemyFires();
        }
    }
    void EnemyFires()
    {
        Transform point = FirePoints;
        var go = Instantiate(bulletPrefab);
        go.GetComponent<Rigidbody2D>().velocity = point.up * -speed;
        go.transform.position = point.position;     
    }
}
